<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="ext.tianma.bom.service.sqe.SQEPartHelper"%>
<%@page import="ext.tianma.bom.service.sqe.SQEWriteExcel"%>
<%@page import="org.json.JSONObject"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
String path = request.getContextPath();
request.setCharacterEncoding("utf-8");
//SQEWriteExcel.test();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SQE Show</title>

<link rel="stylesheet" href="../padShow/font/iconfont.css">
<style type="text/css">
 body{
            background:#ddecf5;
        }

#box3{
    position: relative;
    margin:12% 37%;
    height: 200px;
    padding-left: 3%;
    padding-top: 0%;
    width: 32%;
    background-color: white;
    }
    
    #box2{
    position: absolute;
    width: 50%;
    margin-left: 100%;
    margin-top: -45%;
    z-index: 9;
    } 

#font2 {
    font-family:verdana;
    font-size: 45px;
    font-weight: 900;
    color: #cdcdcd;
    padding-left: 2%;
}

#box1{
    height: 50px; 
    padding-left: 30px; 
    margin-top: 20px;
    }
    
#box0{
    float: inline-start;
    width: 100%;
    background-color: white;
    padding-top: 1px;
    margin-top: 0%;
}

#box3  i{
    font-size:190px;
    color:#cdcdcd;
    margin: auto auto;
}
table {
    position: absolute;
    border: 1px solid #666;
    margin-left:10px;
    margin-top:38px;
    width: 90%;
    border-collapse: collapse;
    background-color: white;
    }



td {
    vertical-align: middle;
    text-align: center;
    height: 28px;
    }
    
 

th {
    border: 1px solid #666;
    font-family: 'Microsoft YaHei';
    font-size: 17px;
    font-weight: 500;
    height: 35px;
    background-color: #eee;
}
    
ul {
    width: 175px;
    border: 1px solid #B7D5EA;
    position: absolute;
    top: 67px;
    left: 74px;
    box-sizing: border-box;
    padding: 0;
    font-size: 12px;
    list-style: none;
    border-top: 0px;
}

ul li {
    line-height: 24px;
    color: black;
    box-sizing: border-box;
    background-color: white;
    list-style-type: none;
    display: block;
    text-indent: 0.5em;
}

ul li:hover {
    background: #eee;
}
#box4{
position:relative;
display: inline;
}

tr:hover{
    background-color: #eee;
}
.tr1{background-color: #eee;}

.tr2{background-color: white;}
</style>


</head>
<script type="text/javascript" src="../../javascript/jQuery1.7.js"></script>
<script type="text/javascript" src="../../javascript/jquery.cookie.js"></script>
<script type="text/javascript" src="../../javascript/history.js"></script>

<script type="text/javascript">   
    self.focus(); 
   </script>
        
    <script type="text/javascript">
    
        function check() {
            var number = document.getElementById("number").value;
            var numType = document.getElementById("numType").value;
            if(numType == ""){
                alert("请选择搜索类型");
            } else if (number=="请输入“成品编码”或“项目编码”!" || number=="") {
                alert("请输入“成品编码”或“项目编码”!");
            } else{
                var obj = document.getElementById("box3");
                if(obj.style.display==""){
                obj.style.display = "none";  
                } else{
                    
                } 
                submit(number,numType);
            }
        }
       
        $(function(){
            $.ajaxSetup ({
            cache: false //关闭AJAX缓存
            });
            });
        
        
            function submit(number,numType){
                
        $.ajax({
            scriptCharset: 'utf-8', 
                    type : "get",
                    url : "<%=path %>/app/sqe/sqePart?numType="
                        + encodeURI(numType) + "&number=" + encodeURIComponent(number) ,
                    data : {},
                    dataType: 'text', 
                    //contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success : function(msg) {
                        $('#tb tr:gt(0)').remove();//删除之前的数据
                        
                        var str = msg;
                        var dataObj = eval("(" + str + ")");
                        if(dataObj.status == "failed"){
                            var arr = dataObj.datalist;
                            var errorNum = arr.join(",");
                            var type;
                            if(numType=="part"){
                            	type = "成品";
                            }else{
                            	type = "项目";
                            }
                            alert("编号为" +errorNum+ "的" +type+ "不存在，请重新输入！");
                        } else if(dataObj.status=="success"){
                            var arrobj = dataObj.datalist;
                            var s = '';
                            for(var i=0;i<arrobj.length;i++){
                                    var url = "<a href=\"Javascript:var processWindow = window.open('"
                                        + "<%=path %>/"
                                        + "netmarkets/jsp/sqe/sqeMaterial.jsp?number="
                                        + arrobj[i].partNumber
                                        + "&view="
                                        + arrobj[i].viewName
                                        + "', '_blank', 'height=520, width=1050, top=70, left=250,resizable=no,scrollbars=yes,menubar=no,toolbar=no,location=no,status=no');\">"
                                        +arrobj[i].partNumber
                                        +"</a>"; 
                                var j = i+1;
                                s = '<tr><td>' +j+'</td><td>' + url + '</td><td>' + arrobj[i].partName + '</td><td>' + arrobj[i].viewName +'</td><td>' +
                                arrobj[i].partDescription + '</td><td>' + arrobj[i].projectNumber + '</td><td>' + arrobj[i].projectName + '</td></tr>';
                                $('#tb').append(s); 
                                
                            }
                            setColor();
                        }
                    },
                    error: function (XMLResponse) {
                        alert(" 错误信息：" + XMLResponse.responseText);
                    }
                })
        }
            
            function setColor(){
              　　var trs=document.getElementById("tb").getElementsByTagName("tr");//获取tbid的table中所有tr的信息
                    for(var i=0;i<trs.length;i++)
                    {
                          　　　　if(i%2==0){
                              trs[i].className="tr1";
                          　　　　}else{
                              trs[i].className="tr2";  
                          　　　　}
                    }
            }
    </script>


<body>
        <div id="box0">
            <div id="box1">
                <span>搜索类型:</span><span>
                    <select id="numType" name="numType" >
                        <option value="" selected="selected">请选择搜索类型：</option>
                        <option value="part" id="partType">成品编码</option>
                        <option value="project" id="docType">项目编码</option>
                    </select> </span> 
                    
                <span style=" margin-left: 10px;" >编号:</span>   
                <span>
                    <div id="box4">
                        <input type="text" id="number" value="请输入“物料编码”或“项目编码”!" style="width: 170px;"
                        onfocus="javascript:if(this.value=='请输入“物料编码”或“项目编码”!')this.value='';">
                        
                        <!-- onfocus="this.value='';" -->
                        <div id="box2">
                            <ul id="history">
                            </ul>
                        </div>
                    </div>
                    <button id="btn1" onclick="toSearch();check()"><i class="iconfont">&#xe60b;</i></button>
                </span>

        <hr color="black" width=93% style="position: absolute; margin-top: 2%;margin-left: -1%" />

        <table id="tb" border="2" cellpadding="1" cellspacing="1" bordercolor="#ccc">
            <tr>
                <th>序号</th>
                <th>成品物料编号</th>
                <th>物料名称</th>
                <th>视图</th>
                <th>物料描述</th>
                <th>项目编码</th>
                <th>项目名称</th>
            </tr>
        </table>
        
        
        
    
    
        </div>
        
        <div id="box3" style="display:">
          <i class="iconfont">&#xe63b;</i>
          <p><font id="font2" >暂无数据</font></p>
        </div>
       </div> 
</body>
</html>